var loginSubmitData = {
   init: function (field) {
      //后台验证
      var loginBoolean = false;
      layui.kaAjax.ajax(layui.kaBgUrl.url("login"), function (rs) { // rs 返回的驗證碼 JSON
         if (rs.code == 200) {
            loginBoolean = true;
            top.currentUser = rs.kaLoginDataParam;
            //设置token 
            var tokenAuth = rs.token;
            layui.kaToken.set(tokenAuth);
            // 账号登录
            if (rs.LoginBody.loginMode == "0") {
               // 判断记住密码
               if (rs.LoginBody.automaticLogon == 1) {
                  field.code = "";
                  field.loginMode = "0";
                  field.clientType = "";
                  field.clientMsg = "";
                  field.frontEndUrl = "";
                  localStorage.setItem(loginAutomaticLogonName, JSON.stringify(field));
               } else if (rs.LoginBody.automaticLogon == 0) {
                  localStorage.removeItem(loginAutomaticLogonName);
               }
            } else if (rs.LoginBody.loginMode == "1") {
               // 清除
               sessionStorage.removeItem("phonenVerCodePhone");
               sessionStorage.removeItem("phonenVerCodeTime");
               layui.kaInterval.clear("phonenVerCodeButton");
            } else if (rs.LoginBody.loginMode == "2") {
               // 清除
            }
            //设置登录 cookie
            document.cookie = "Authorization=" + tokenAuth + "; path=/";
            layui.kaCookie.set("username", top.currentUser.userName, 30, "/", location.hostname);
            layui.kaCookie.set("tenant", top.currentUser.tenant, 30, "/", location.hostname);
            layui.kaCookie.set("phonenumber", top.currentUser.phonenumber, 30, "/", location.hostname);
            layui.kaCookie.set("rememberMe", "true", 30, "/", top.currentUser.hostname);
            layui.kaCookie.set("password", top.currentUser.password, 30, "/", location.hostname);
            layui.kaCookie.set("Authorization", tokenAuth, 2, "/", location.hostname);
            var kts = top.currentUser.userName[0].toUpperCase() + top.currentUser.userName.slice(1);
            layui.kaCookie.set("Admin-Token", tokenAuth, 2, "/", location.hostname);
            layui.kaCookie.set("tenantId", "default", 30, "/", location.hostname);
         } else {
            layui.kaAjax.ajax(layui.kaBgUrl.url("captchaImage"), function (rs) {
               if (rs.code == 200) {
                  var imgsrc = "data:image/gif;base64," + rs.img;//驗證碼
                  layui.$("#verificationImg").attr("src", imgsrc);
                  layui.$("#uuid").val(rs.uuid);
               }
            })
            layui.kaMsg.error(rs.msg, JSON.stringify(rs));
         }
      }, field);
      // 处理成功后操作
      if (loginBoolean) {
         //跳转页面
         layui.kaMsg.success("<div>登录成功</div><div>正在切换页面</div>", JSON.stringify(field), function () {
            location.href = "./sysAppList.html"
         });
      }
   }
}